gadget: add API to get various area boxes
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 24 Feb 2016 22:21:10 +0000 (14:21 -0800)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 29 Feb 2016 18:45:13 +0000 (10:45 -0800)
Compared to the function returning the allocation, these will return the
box in gadget coordinates.

gtk/gtkcssgadget.c
gtk/gtkcssgadgetprivate.h

index af7afb5998d959c4133c42a242465cb9c0f4ef54..1c68a7afce09bd8662f908349c7f042412cc80b4 100644 (file)
@@ -956,6 +956,57 @@ gtk_css_gadget_queue_draw (GtkCssGadget *gadget)
   gtk_widget_queue_draw (gtk_css_gadget_get_owner (gadget));
 }
 
+/**
+ * gtk_css_gadget_get_margin_box:
+ * @gadget: a #GtkCssGadget
+ * @box: (out): Return location for gadget's the margin box
+ *
+ * Returns the margin box of the gadget. The box coordinates are relative to
+ *   the gadget origin. Compare with gtk_css_gadget_get_margin_allocation(),
+ *   which returns the margin box in the widget allocation coordinates.
+ */
+void
+gtk_css_gadget_get_margin_box (GtkCssGadget  *gadget,
+                               GtkAllocation *box)
+{
+  gtk_css_gadget_get_margin_allocation (gadget, box, NULL);
+  shift_allocation (gadget, box);
+}
+
+/**
+ * gtk_css_gadget_get_border_box:
+ * @gadget: a #GtkCssGadget
+ * @box: (out): Return location for gadget's the border box
+ *
+ * Returns the border box of the gadget. The box coordinates are relative to
+ *   the gadget origin. Compare with gtk_css_gadget_get_border_allocation(),
+ *   which returns the border box in the widget allocation coordinates.
+ */
+void
+gtk_css_gadget_get_border_box (GtkCssGadget  *gadget,
+                               GtkAllocation *box)
+{
+  gtk_css_gadget_get_border_allocation (gadget, box, NULL);
+  shift_allocation (gadget, box);
+}
+
+/**
+ * gtk_css_gadget_get_content_box:
+ * @gadget: a #GtkCssGadget
+ * @box: (out): Return location for gadget's the content box
+ *
+ * Returns the content box of the gadget. The box coordinates are relative to
+ *   the gadget origin. Compare with gtk_css_gadget_get_content_allocation(),
+ *   which returns the content box in the widget allocation coordinates.
+ */
+void
+gtk_css_gadget_get_content_box (GtkCssGadget  *gadget,
+                                GtkAllocation *box)
+{
+  gtk_css_gadget_get_content_allocation (gadget, box, NULL);
+  shift_allocation (gadget, box);
+}
+
 void
 gtk_css_gadget_get_margin_allocation (GtkCssGadget  *gadget,
                                       GtkAllocation *allocation,
index 657813583c9fbfe03b39d58ce1f41436f3e929d2..fa3c40902884ae4b3cdd252038cc4608f005ecd5 100644 (file)
@@ -93,6 +93,12 @@ gboolean        gtk_css_gadget_border_box_contains_point (GtkCssGadget
 gboolean        gtk_css_gadget_content_box_contains_point (GtkCssGadget         *gadget,
                                                            int                   x,
                                                            int                   y);
+void            gtk_css_gadget_get_margin_box           (GtkCssGadget           *gadget,
+                                                         GtkAllocation          *box);
+void            gtk_css_gadget_get_border_box           (GtkCssGadget           *gadget,
+                                                         GtkAllocation          *box);
+void            gtk_css_gadget_get_content_box          (GtkCssGadget           *gadget,
+                                                         GtkAllocation          *box);
 
 void            gtk_css_gadget_add_class                (GtkCssGadget           *gadget,
                                                          const char             *name);